var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({
    extended: false
}));
app.use(cookieParser("user")); //密钥"user"
app.use("/admin", express.static(path.join(__dirname, './public/admin'))); //通过/admin访问后台
app.use("/upload", express.static(path.join(__dirname, './public/upload')));
app.use("/", express.static(path.join(__dirname, './public/www'))); //通过/访问前台

//注册控制权限的中间件
app.use(require("./permission"));


//在这里注册路由
app.use("/api/User", require("./routes/User"));
app.use("/api/article", require("./routes/article"));
app.use("/articleUpload", require("./routes/articleUpload"));

app.use("/api/Cinema", require("./routes/Cinema")); //影院的路

app.use("/api/MovieAndCinema", require("./routes/MovieAndCinema"));

app.use("/api/Movie", require("./routes/Movie"));

app.use("/api/upload", require("./routes/upload"));
module.exports = app;
